package com.java83.service.impl;

import java.util.List;

import com.java83.domain.LzhServicer;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.java83.mapper.LzhServicerMapper;
import com.java83.service.LzhServicerService;
import springfox.documentation.annotations.Cacheable;

/**
 * 服务者Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-02-17
 */
@Service
public class LzhServicerServiceImpl implements LzhServicerService
{
    @Autowired
    private LzhServicerMapper lzhServicerMapper;
    /**
     * 查询服务者
     * 
     * @param id 服务者主键
     * @return 服务者
     */
    @Override
    public LzhServicer selectLzhServicerById(Long id)
    {
        return lzhServicerMapper.selectLzhServicerById(id);
    }

    /**
     * 查询服务者列表
     * 
     * @param lzhServicer 服务者
     * @return 服务者
     */
    @Override
    public List<LzhServicer> selectLzhServicerList(LzhServicer lzhServicer)
    {
        return lzhServicerMapper.selectLzhServicerList(lzhServicer);
    }
    /**
     * 查询服务者列表
     *
     * @param lzhServicer 服务者
     * @return 服务者
     */
    @Cacheable(value = "lzhServicer")
    @Override
    public List<LzhServicer> selectLzhServicerList2(LzhServicer lzhServicer)
    {
        lzhServicer.setUid(SecurityUtils.getUserId());
        return lzhServicerMapper.selectLzhServicerList(lzhServicer);
    }
    /**
     * 新增服务者
     * 
     * @param lzhServicer 服务者
     * @return 结果
     */
    @Override
    public int insertLzhServicer(LzhServicer lzhServicer) {
        if (lzhServicer.getUid()==null) {
            lzhServicer.setUid(SecurityUtils.getUserId());
        }
        System.out.println(lzhServicer.getNametwo());
        return lzhServicerMapper.insertLzhServicer(lzhServicer);
    }

    /**
     * 修改服务者
     * 
     * @param lzhServicer 服务者
     * @return 结果
     */
    @Override
    public int updateLzhServicer(LzhServicer lzhServicer)
    {
        System.out.println(lzhServicer.getId());
        return lzhServicerMapper.updateLzhServicer(lzhServicer);
    }

    /**
     * 批量删除服务者
     * 
     * @param ids 需要删除的服务者主键
     * @return 结果
     */
    @Override
    public int deleteLzhServicerByIds(Long[] ids)
    {
        return lzhServicerMapper.deleteLzhServicerByIds(ids);
    }

    /**
     * 删除服务者信息
     * 
     * @param id 服务者主键
     * @return 结果
     */
    @Override
    public int deleteLzhServicerById(Long id)
    {
        return lzhServicerMapper.deleteLzhServicerById(id);
    }

    @Override
    public String getEmployeeDepartmentName() {
        LzhServicer employee = lzhServicerMapper.findLastOne();
        System.out.println(employee.getId());
        // 数据库没有数据
        if (employee == null) {
            return "a00" + "1";
        } else {
            // 数据库中有数据
            String planId = String.valueOf(employee.getSid());
            // 获取"S00"
            String str1 = planId.substring(0, 1);


            String name = null;

                name = str1 + (employee.getId() + 1);


            return name;
        }
    }
}
